import QtQuick 2.15
import Qt5Compat.GraphicalEffects

Rectangle {
    id: maskRect
    property int size: 80
    property bool load: false
    property string loadIcon: "qrc:/icon/loading.svg"
    property bool mask: true
    anchors.fill: parent
    color: "#2f000000"
    opacity: load ? 1 : 0
    Behavior on opacity {
        NumberAnimation {
            duration: 200
        }
    }
    Rectangle {
        anchors.centerIn: parent
        width: size
        height: size
        opacity: load ? 1 : 0
        color: "#fff"
        radius: 20
        Behavior on opacity {
            NumberAnimation {
                duration: 200
            }
        }
        Image {
            id: image
            anchors.centerIn: parent
            width: parent.width * 0.8
            height: parent.height * 0.8
            source: loadIcon
            ColorOverlay {
                anchors.fill: parent
                source: parent
                color: p_theme.currentTheme().fontColor
            }
            RotationAnimation {
                id: rotationAnimation
                target: image
                property: "rotation"
                from: 0
                to: 360
                duration: 1000 // 旋转一周的时间（毫秒）
                loops: Animation.Infinite // 无限循环
                easing.type: Easing.InOutExpo
            }
        }
    }

    onLoadChanged: {
        rotationAnimation.running = load;
    }
}
